package bairui.international.model.domain.jpa;

import com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue;

/**
 *
 * (用户积分记录)TB_UserGradeRecord
 *
 * @说明
 * <pre>

 * </pre>
 *
 * @see Help_TB_UserGradeRecord#inheritance() 继承体系信息
 *
 */
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate

@javax.persistence.Entity(name="t_userGradeRecord")
@com.lianjing.sh.processing.info.annotation.GenerateInfoModel
@SuppressWarnings("serial")
@com.lianjing.sh.model.common.annotation.Comment("用户积分记录")
@com.lianjing.sh.processing.info.annotation.InfoComment("用户积分记录")
public class TB_UserGradeRecord
 extends TBSuper_BaseIDAndTimeAndOrderValue
 implements 
	com.lianjing.sh.model.common.stardard.TableModel<Long>,
	com.sh_lianjing.state.HasStatable,
	java.io.Serializable

{

	
	
	/**
	 * 必须属性赋值接口
	 */
	public static interface MustProperties{
		/** 积分 */
		public Double getScore();
		/** 用户 */
		public bairui.international.model.domain.jpa.TB_User getUser();
		/** 类型 */
		public bairui.international.model.type.Type_UserGrade getType();
		/** 当前积分 */
		public Double getCurrentScore();
	}
	
	/**
	 * 为必须属性赋值
	 */
	public TB_UserGradeRecord properties(MustProperties properties) {
		this.setScore(properties.getScore());
		this.setUser(properties.getUser());
		this.setType(properties.getType());
		this.setCurrentScore(properties.getCurrentScore());
		return this;
	}
	
	/**
	 *	必须属性构造函数
	 */
	public TB_UserGradeRecord(MustProperties properties) {
		this.properties(properties);
	}
	
	
	/**
	 * 可选单属性赋值接口
	 */
	public static interface OptionalSingleProperties{
		/** 产品订单 */
		public bairui.international.model.domain.jpa.TB_ProductOrder getProductOrder();
		/** 产品订单状态 */
		public bairui.international.model.status.State_ProductOrder getState();
	}
	
	/**
	 * 为可选单属性赋值
	 */
	public TB_UserGradeRecord properties(OptionalSingleProperties properties) {
		this.setProductOrder(properties.getProductOrder());
		this.setState(properties.getState());
		return this;
	}
	
	
	
	public TB_UserGradeRecord(MustProperties must, OptionalSingleProperties optionalSingle) {
		this.properties(must);
		this.properties(optionalSingle);
	}
	
	/**
	 * 仅当前必须属性赋值接口
	 */
	public static interface CurrentMustProperties{
		/** 积分 */
		public Double getScore();
		/** 用户 */
		public bairui.international.model.domain.jpa.TB_User getUser();
		/** 类型 */
		public bairui.international.model.type.Type_UserGrade getType();
		/** 当前积分 */
		public Double getCurrentScore();
	}
	
	/**
	 * 为仅当前必须属性赋值
	 */
	public TB_UserGradeRecord properties(CurrentMustProperties properties) {
		this.setScore(properties.getScore());
		this.setUser(properties.getUser());
		this.setType(properties.getType());
		this.setCurrentScore(properties.getCurrentScore());
		return this;
	}
	
	/**
	 * 仅当前可选单属性赋值接口
	 */
	public static interface CurrentOptionalSingleProperties{
		/** 产品订单 */
		public bairui.international.model.domain.jpa.TB_ProductOrder getProductOrder();
		/** 产品订单状态 */
		public bairui.international.model.status.State_ProductOrder getState();
	}
	
	/**
	 * 为仅当前可选单属性赋值
	 */
	public TB_UserGradeRecord properties(CurrentOptionalSingleProperties properties) {
		this.setProductOrder(properties.getProductOrder());
		this.setState(properties.getState());
		return this;
	}
	
	public TB_UserGradeRecord(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean,
		CurrentMustProperties mustProperties,
		CurrentOptionalSingleProperties optionalProperties
	) {
		this(bean);
		this.properties(mustProperties);
		this.properties(optionalProperties);
	}
	
	public TB_UserGradeRecord(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean
	) {
		update(bean);
	}
	
	public TB_UserGradeRecord update(com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean){
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		return this;
	}
	
	
	/**
	 * 更新属性内部类
	 */
	public abstract class UpdateProperties {
	
		public UpdateProperties() throws Exception {
			Integer orderValue = getOrderValue(TB_UserGradeRecord.this);
			if(isOverride_getOrderValue){
				TB_UserGradeRecord.this.setOrderValue(orderValue);
			}
	
			Double score = getScore(TB_UserGradeRecord.this);
			if(isOverride_getScore){
				TB_UserGradeRecord.this.setScore(score);
			}
	
			bairui.international.model.domain.jpa.TB_User user = getUser(TB_UserGradeRecord.this);
			if(isOverride_getUser){
				TB_UserGradeRecord.this.setUser(user);
			}
	
			bairui.international.model.domain.jpa.TB_ProductOrder productOrder = getProductOrder(TB_UserGradeRecord.this);
			if(isOverride_getProductOrder){
				TB_UserGradeRecord.this.setProductOrder(productOrder);
			}
	
			bairui.international.model.type.Type_UserGrade type = getType(TB_UserGradeRecord.this);
			if(isOverride_getType){
				TB_UserGradeRecord.this.setType(type);
			}
	
			Double currentScore = getCurrentScore(TB_UserGradeRecord.this);
			if(isOverride_getCurrentScore){
				TB_UserGradeRecord.this.setCurrentScore(currentScore);
			}
	
			bairui.international.model.status.State_ProductOrder state = getState(TB_UserGradeRecord.this);
			if(isOverride_getState){
				TB_UserGradeRecord.this.setState(state);
			}
		}
	
		public TB_UserGradeRecord up(){
			return TB_UserGradeRecord.this;
		}
	
		/** 排序值 */
		private boolean isOverride_getOrderValue = true;
		public Integer getOrderValue(TB_UserGradeRecord it) throws Exception { 
			isOverride_getOrderValue = false; 
			return null;
		}
		/** 积分 */
		private boolean isOverride_getScore = true;
		public Double getScore(TB_UserGradeRecord it) throws Exception { 
			isOverride_getScore = false; 
			return null;
		}
		/** 用户 */
		private boolean isOverride_getUser = true;
		public bairui.international.model.domain.jpa.TB_User getUser(TB_UserGradeRecord it) throws Exception { 
			isOverride_getUser = false; 
			return null;
		}
		/** 产品订单 */
		private boolean isOverride_getProductOrder = true;
		public bairui.international.model.domain.jpa.TB_ProductOrder getProductOrder(TB_UserGradeRecord it) throws Exception { 
			isOverride_getProductOrder = false; 
			return null;
		}
		/** 类型 */
		private boolean isOverride_getType = true;
		public bairui.international.model.type.Type_UserGrade getType(TB_UserGradeRecord it) throws Exception { 
			isOverride_getType = false; 
			return null;
		}
		/** 当前积分 */
		private boolean isOverride_getCurrentScore = true;
		public Double getCurrentScore(TB_UserGradeRecord it) throws Exception { 
			isOverride_getCurrentScore = false; 
			return null;
		}
		/** 产品订单状态 */
		private boolean isOverride_getState = true;
		public bairui.international.model.status.State_ProductOrder getState(TB_UserGradeRecord it) throws Exception { 
			isOverride_getState = false; 
			return null;
		}
	
	}
	
	
	/**
	 * 构造函数
	 */
	public TB_UserGradeRecord() {
	}
	
	public TB_UserGradeRecord(
		@lombok.NonNull Long id
	) {
		this.setId(id);
	}
	
	public TB_UserGradeRecord(
		@lombok.NonNull TB_UserGradeRecord bean
	) {
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		this.setScore(bean.getScore());
		this.setUser(bean.getUser());
		this.setProductOrder(bean.getProductOrder());
		this.setType(bean.getType());
		this.setCurrentScore(bean.getCurrentScore());
		this.setState(bean.getState());
	}
	
	

	


	/**
	 * 属性
	 */
	@com.lianjing.sh.model.common.annotation.Comment("积分")
	@com.lianjing.sh.processing.info.annotation.InfoComment("积分")
	@javax.persistence.Column(name="score", nullable=false)
	private Double score;

	@com.lianjing.sh.model.common.annotation.Comment("用户")
	@com.lianjing.sh.processing.info.annotation.InfoComment("用户")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_User user;

	@com.lianjing.sh.model.common.annotation.Comment("产品订单")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品订单")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne()
	private bairui.international.model.domain.jpa.TB_ProductOrder productOrder;

	@com.lianjing.sh.model.common.annotation.Comment("类型")
	@com.lianjing.sh.processing.info.annotation.InfoComment("类型")
	@javax.persistence.Enumerated(javax.persistence.EnumType.STRING)
	@javax.persistence.Column(name="type", nullable=false)
	private bairui.international.model.type.Type_UserGrade type;

	@com.lianjing.sh.model.common.annotation.Comment("当前积分")
	@com.lianjing.sh.processing.info.annotation.InfoComment("当前积分")
	@javax.persistence.Column(name="currentScore", nullable=false)
	private Double currentScore;

	@com.lianjing.sh.model.common.annotation.Comment("产品订单状态")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品订单状态")
	@javax.persistence.Enumerated(javax.persistence.EnumType.STRING)
	@javax.persistence.Column(name="state")
	private bairui.international.model.status.State_ProductOrder state;

	/** get[积分] */
	public Double getScore() {
		return this.score;
	}

	/** get[用户] */
	public bairui.international.model.domain.jpa.TB_User getUser() {
		return this.user;
	}

	/** get[产品订单] */
	public bairui.international.model.domain.jpa.TB_ProductOrder getProductOrder() {
		return this.productOrder;
	}

	/** get[类型] */
	public bairui.international.model.type.Type_UserGrade getType() {
		return this.type;
	}

	/** get[当前积分] */
	public Double getCurrentScore() {
		return this.currentScore;
	}

	/** get[产品订单状态] */
	public bairui.international.model.status.State_ProductOrder getState() {
		return this.state;
	}

	/** set[积分] */
	public void setScore(Double score) {
		this.score = score;
	}

	/** set[用户] */
	public void setUser(bairui.international.model.domain.jpa.TB_User user) {
		this.user = user;
	}

	/** set[产品订单] */
	public void setProductOrder(bairui.international.model.domain.jpa.TB_ProductOrder productOrder) {
		this.productOrder = productOrder;
	}

	/** set[类型] */
	public void setType(bairui.international.model.type.Type_UserGrade type) {
		this.type = type;
	}

	/** set[当前积分] */
	public void setCurrentScore(Double currentScore) {
		this.currentScore = currentScore;
	}

	/** set[产品订单状态] */
	public void setState(bairui.international.model.status.State_ProductOrder state) {
		this.state = state;
	}

	public void assignUser(bairui.international.model.domain.jpa.TB_User user) {
		if(null != user){
			user.addUserGradeRecords(this);
		}
		this.setUser(user);
	}
	

	public void assignProductOrder(bairui.international.model.domain.jpa.TB_ProductOrder productOrder) {
		if(null != productOrder){
			productOrder.addUserGradeRecords(this);
		}
		this.setProductOrder(productOrder);
	}
	

	
	
	

	/** take[用户] */
	public bairui.international.model.domain.jpa.TB_User takeUser(){
		if(null == this.user){
			this.user = new bairui.international.model.domain.jpa.TB_User();
		}
		return this.user;
	}
	
	/** take[产品订单] */
	public bairui.international.model.domain.jpa.TB_ProductOrder takeProductOrder(){
		if(null == this.productOrder){
			this.productOrder = new bairui.international.model.domain.jpa.TB_ProductOrder();
		}
		return this.productOrder;
	}
	
	/** must[用户] */
	public bairui.international.model.domain.jpa.TB_User mustUser() {
		return this.user;
	}
	
	/** optional[产品订单] */
	public java.util.Optional<bairui.international.model.domain.jpa.TB_ProductOrder> optionalProductOrder() {
		return java.util.Optional.ofNullable(this.productOrder);
	}
	

	/**
	 * 复写 hashCode
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		return prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
	}
	
	/**
	 * 复写 equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		TB_UserGradeRecord other = (TB_UserGradeRecord) obj;
		if (this.getId() == null) {
			return false;
		} else if (!this.getId().equals(other.getId())){
			return false;
		}
		return true;
	}
	

	/**
	 * 用来覆盖toString()的输出
	 */
	@javax.persistence.Transient
	private String toString;
	
	public void setToString(String toString) {
		this.toString = toString;
	}
	
	/**
	 * 复写 toString
	 */
	@Override
	public String toString() {
		if(null != this.toString){
			return this.toString;
		}
		return super.toString();
	}	

	@javax.persistence.PrePersist
	public void prePersist() {
		this.setCreateTime(new java.util.Date());
		this.setModifyTime(new java.util.Date());
	}
	
	@javax.persistence.PreUpdate
	public void preUpdate() {
		this.setModifyTime(new java.util.Date());
	}

	/**
	 * 状态相关
	 */
	public bairui.international.model.status.State_ProductOrder state(){
		return this.getState();
	}


}
